/*
 * main.cpp
 *
 *  Created on: 11 nov. 2011
 *      Author: pierre
 */

#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include "calculsoustableau.h"
#include "tbb/tbb.h"

int main(){
//declaration variable
    std::cout<<"declaration variable"<<endl;
    vector<int> cgh;
    vector<int> cgh1;
    int x0,x1;
    struct result resultatfinal;
//declaration pointeur
    struct result *presultatfinal;
    vector<int> *pcgh;
    vector<int> *pcgh1;
//affectation des pointeur
        presultatfinal=&resultatfinal;
        pcgh=&cgh;
        pcgh1=&cgh1;
//test fonction
	resultatfinal.m=-32000;
	for (int i=0;i<=20000;i++){
		cgh.push_back(i);
		cgh1.push_back(i+200);
	};
    x0=2;
    x1=3;
    //creation objet calcule calc();
    calcule& calc = *new(tbb::task::allocate_root()) calcule(pcgh,x0,x1,presultatfinal);
    calcule& calc0 = *new(tbb::task::allocate_root()) calcule(pcgh1,x0,x1,presultatfinal);
    std::cout<<"entrée calcule sous tableau"<<endl;
    tbb::task::spawn_root_and_wait(calc0);
    std::cout<<"resultat final x0= "<<resultatfinal.x0<<" x1= "<<resultatfinal.x1<<" y0= "<<resultatfinal.y0<<" y1= "<<resultatfinal.y1<<" M= "<<resultatfinal.m<<endl;
    return 0;
}


